import { BaseAttributes } from '../../types/sequelize'
import { DataTypes, Model } from 'sequelize'
import { sequelize } from '../../config/sequelizeBase'
import BaseColumn from '../base'

class User extends Model<BaseAttributes> {
  username: string
  secret: string
  phone: string
  email: string
  avatar: string
  salt?: string
}

User.init(
  {
    ...BaseColumn,
    username: { type: DataTypes.STRING, unique: true },
    secret: { type: DataTypes.STRING, unique: true },
    phone: { type: DataTypes.STRING },
    email: { type: DataTypes.STRING },
    avatar: { type: DataTypes.STRING },
    salt: { type: DataTypes.STRING, unique: true },
  },
  {
    tableName: 'user',
    freezeTableName: true,
    sequelize,
  },
)

export default User
